/**
 * @file function1.h
 * @brief The given function.
 * @author XDDDD
 * @version 
 * @date 2021-04-28
 */

#ifndef __PAISLEYPARK__FUNCTION1_H__
#define __PAISLEYPARK__FUNCTION1_H__

#include "VectorFunction.h"
#include <cmath>

class function1 : public VectorFunction<6, 6> {
public:
	Point<6> operator()(const Point<6>& _p) const {
		Point<6> t;
		double miu = 1.0/81.45;
		double deno_1 = _p[1]*_p[1] + _p[2]*_p[2] + (_p[0] + miu - 1.0)*(_p[0] + miu - 1.0); 
		deno_1 = deno_1*deno_1*deno_1;
		deno_1 = sqrt(deno_1);
		double deno_2 = _p[1]*_p[1] + _p[2]*_p[2] + (_p[0] + miu)*(_p[0] + miu); 
		deno_2 = deno_2*deno_2*deno_2;
		deno_2 = sqrt(deno_2);
		t[0] = _p[3];
		t[1] = _p[4];
		t[2] = _p[5];
		t[3] = 2.0*_p[4] + _p[0] - miu*(_p[0] + miu - 1.0)/deno_1 - (1.0 - miu)*(_p[0] + miu)/deno_2;
		t[4] = -2.0*_p[3] + _p[1] - miu*_p[1]/deno_1 - (1.0 - miu)*_p[1]/deno_2;
		t[5] = -_p[2]*miu/deno_1 - _p[2]*(1.0 - miu)/deno_2;
		return t;
	}
};

#else
//Do nothing.
#endif
